package com.gragra.sampling.binary.tests;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import com.gragra.sampling.binary.PairCounter;
/**
 * 
 * @author Christoph Teichmann
 * 17.09.2013
 */
public class TestPairCounter
{
	/**
	 * 
	 */
	private PairCounter pc;
	@Before
	public void setUp() throws Exception
	{
		pc = new PairCounter();
		pc.add(5, 20, 7.0);
		pc.add(2, 3, 4.1);
		pc.add(5,20,-3.0);
		pc.add(2, 3, -4.1);
	}
	@Test
	public void testClear()
	{
		assertEquals(pc.get(0, 0),0.0,0.0000001);
		assertEquals(pc.get(5, 20),4.0,0.0000001);
		assertEquals(pc.get(2, 3),0.0,0.0000001);
		pc.clear();
		assertEquals(pc.get(0, 0),0.0,0.0000001);
		assertEquals(pc.get(5, 20),0.0,0.0000001);
		assertEquals(pc.get(2, 3),0.0,0.0000001);
	}
	@Test
	public void testSet()
	{
		assertEquals(pc.get(2, 3),0.0,0.0000001);
		pc.set(2, 3, 5.0);
		assertEquals(pc.get(2, 3),5.0,0.0000001);
	}
}